home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / Installer / Script Examples / File Compare by Procedure / GetFileVersion.c next >
Encoding:
Text File  |  1994-08-30  |  1.7 KB  |  65 lines  |  [TEXT/MPS ]

  1. //
  2. //    GetFileVersion.c
  3. //
  4. //        This code resource will be called as a Custom Version Compare
  5. //        Procedure ( 'invc' ) from within the "File Compare by Procedure"
  6. //        example.
  7. //
  8. //        The function below simply reads the first 4 bytes of the 'vers' (1)
  9. //        resource item of the currently selected file ( handle automatically
  10. //        by the Installer ), and returns that value. If a 'vers' (1) resource
  11. //        item cannot be found, then the value of the first four bytes of the
  12. //        'vers' (2) resource item is returned. If no 'vers' (1) or (2) resource
  13. //        items are found, then the function returns 0.
  14. //
  15. //        This by the way, is the default behavior of the Installer when
  16. //        ascertaining the version number of a file, so this function when
  17. //         implemented does not really do anything. But since this is a custom
  18. //        code resource, we don't really know what you'll want to do with it
  19. //        exactly. Customize this example as best fits the needs of your project.
  20. //
  21. //
  22. //        mark young • 08/30/94
  23. //
  24. //        Copyright 1993-1994, Apple Computer, Inc., All Rights Reserved
  25. //
  26.  
  27.  
  28. #ifndef __OSUtils__
  29. #include <OSUtils.h>
  30. #endif
  31.  
  32. #ifndef __Errors__
  33. #include <Errors.h>
  34. #endif
  35.  
  36. #ifndef __Resources__
  37. #include <Resources.h>
  38. #endif
  39.  
  40. // NOTE: The name of this function 'GetFileVersion' should
  41. // match that specified in the -m option for the line in the
  42. // makefile that compiles this code resource.
  43. long GetFileVersion( void ) 
  44. {
  45.  
  46.     long    theVersionNum = 0;
  47.     long**    longHandle;
  48.  
  49.     longHandle = (long**) Get1Resource( 'vers', 1 );
  50.     
  51.     if ( longHandle != NULL && ResError() == noErr )
  52.         {
  53.         theVersionNum = **longHandle;
  54.         }
  55.     else 
  56.          {
  57.         longHandle = (long**) Get1Resource( 'vers', 2 );
  58.  
  59.         if ( longHandle != NULL && ResError() == noErr )
  60.             theVersionNum = **longHandle;
  61.         }
  62.     
  63.     return theVersionNum;
  64. }
  65.